package com.ruoyi.project.pm.progressacceptance.controller;

import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.project.pm.progressacceptance.domain.PMPA;
import com.ruoyi.project.pm.progressacceptance.sevice.PMPAService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 铁蛋儿
 * @date 2020-09-18 14:18
 * @desc 百战程序员 http://www.itbaizhan.com
 *
 * 项目进度验收  控制器  继承封装好的BaseController
 *
 */
@Controller
@RequestMapping("/pm/progressacceptance")
public class PMPAController extends BaseController {

    //前缀字符串  用于跳转到页面
    private String prefix = "/pm/progressacceptance";

    //注入服务层的对象
    @Autowired
    private PMPAService pmpaService;


    /**
     * 用于跳转到项项目进度验收的前端页面
     * @return   返回到templates/pm/progressacceptance/progressacceptance.html页面
     */
    @RequiresPermissions("pm:progressacceptance:view")
    @GetMapping()
    public String progressAcceptance(){
        return prefix + "/progressacceptance";
    }

    @RequiresPermissions("pm:progressacceptance:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(PMPA pmpa){
        //分页开始条件
        startPage();
        //调用服务层的方法查询所有
        List<PMPA> list = pmpaService.selectPMPAList(pmpa);

        //返回分页数据
        return getDataTable(list);
    }

    /**
     * 跳转到进度验收页面
     * @param pmId   带到服务器的id
     * @param model  把服务器查询的数据存放到model中带给页面展示
     * @return
     */
    @GetMapping("/prorec/{pmId}")
//    @ResponseBody
    public String toProRec(@PathVariable("pmId") Integer pmId, Model model){
        System.out.println("pmId=" + pmId);
        System.out.println("跳转到进度验收页面");
        return prefix + "/prorec";
    }

}
